package chapter10;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author lzy
 * @create 2018-03-22 上午8:34
 */
public class TestDemo2 {
    private static final Logger LOGGER = LoggerFactory.getLogger(TestDemo2.class);

    public static void main(String[] args) {
        Book[] books = new Book[]{
                new Book("test1", 12.1),
                new Book("test2", 121.1),
                new Book("test3", 2.1),
                new Book("test4", 92.1)
        };

        Arrays.sort(books, (o1, o2) -> {
            if (o1.getPrice() > o2.getPrice()) {
                return 1;
            } else if (o1.getPrice() < o2.getPrice()) {
                return -1;
            }
            return 0;
        });

        LOGGER.info(Arrays.toString(books));
    }
}
